import {alert} from "../../components/common/alert";

import {get, post} from "../../utils/req";

export const list = async () => {
    try {
        return await get('/private/classroom/list') || [];
    } catch (e) {
        alert(`获取教室信息失败：${e}`, 'error');
        return [];
    }
}

export const remove = async (data) => {
    try {
        await get(`/private/classroom/delete?id=${data.id}`);
        alert(`教室 ${data.name} 已被删除`);
        return true;
    } catch (e) {
        alert(`删除教室失败：${e}`, 'error');
        return false;
    }
}

export const save = async (data) => {
    try {
        await post('/private/classroom/save', data);
        return true;
    } catch (e) {
        alert(`保存教室信息失败：${e}`, 'error');
        return false;
    }
}
